import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

//hashmap去重
public class Java005 {
    public static void main(String[] args) {
        ArrayList<Integer> num1 = new ArrayList<>();
        Collections.addAll(num1,1,2,3);
        ArrayList<Integer> num2 = new ArrayList<>();
        Collections.addAll(num2,3,4,5,2);
        fun(num1,num2);

    }
    public static void fun(ArrayList<Integer> num1,ArrayList<Integer> num2){
        HashMap<Integer,Integer> map = new HashMap<>();
        Set<Map.Entry<Integer,Integer>> entries = map.entrySet();
        ArrayList<Integer>  all = new ArrayList<>();

        //数据流
        Map<Integer, Long> map1 = num1.stream().collect(Collectors.groupingBy(c -> c, Collectors.counting()));

        Map<Integer, Long> map2 = num2.stream().collect(Collectors.groupingBy(c -> c, Collectors.counting()));

        Map<Integer, Long> mapEnd = Stream.concat(map1.entrySet().stream(), map2.entrySet().stream()).collect(Collectors.groupingBy(s -> s.getKey(), Collectors.counting()));

        System.out.println(mapEnd);

        List<Integer> list1 = mapEnd.entrySet().stream().filter(s -> s.getValue() == 1).map(s -> s.getKey()).collect(Collectors.toList());
        System.out.println(list1);

//        mapEnd.entrySet().stream().filter(s->s.getValue()==1).forEach(s->System.out.print(s.getKey()));


        //引用
        System.out.println("======");
        List<Integer> list2 = mapEnd.entrySet().stream().filter(s -> s.getValue() == 1).map(Map.Entry::getKey).collect(Collectors.toList());
        System.out.println(list2);


    }
}
